import { createApp } from 'vue';
import pinia from './store';
import { setupAssets } from './plugins';
import './assets/font/iconfont.css'
import { Input, Picker, Textarea, Button, Tabs, Divider, TabPane,Popup, DatePicker, Form, FormItem, Calendar, Radio, RadioGroup } from '@nutui/nutui-taro'
import { get, post } from './utils/request';
import { Sticky } from '@nutui/nutui-taro'

// import { IconFont } from '@nutui/icons-vue-taro'

import { useUserStore } from './store/user';
import Taro from '@tarojs/taro'

// post('/dictionary/region', {
//   fatherId: 7459 
// }).then(res => {
//   console.log("res", res);
// });

const App = createApp({

  onShow() {
    // 应用启动时恢复用户信息
    const userStore = useUserStore();
    userStore.restoreUserInfo();

    // 判断token
    const token = Taro.getStorageSync('token')
    if(token != null){
      userStore.fetchUserInfo()
    }else{
      Taro.navigateTo({
        url:'/pages/webs/register',
      })
    }
  }
  /** 入口组件不需要实现 render 方法，即使实现了也会被 taro 所覆盖 */
});

// 引入静态资源和样式
setupAssets();

// 注册 Pinia 状态管理
App.use(pinia);
App.use(Input)
App.use(Picker)
App.use(Textarea)
App.use(Button)
App.use(Tabs)
App.use(TabPane)
App.use(Popup)
App.use(DatePicker)
App.use(Form)
App.use(FormItem)
App.use(Calendar)
App.use(Radio)
App.use(RadioGroup)
App.use(Sticky)
App.use(Divider)
// App.use(IconFont)

export default App;
